#include "iPlayerInfo.h"
#include "iPlayerAI.h"
#include "sfGlobals.h"
#include <string>
#include "SWPlayerAI.h"

using namespace std;

iPlayerInfo::iPlayerInfo()
{
	//EZLOGGERSTREAM << "Create Player"<< std::endl;
	seatNumber=0;
	this->player_ai=new SWplayerAI();
}

iPlayerInfo::iPlayerInfo(int seatNum)
{
	seatNumber = seatNum;
	this->player_ai=new SWplayerAI();	
}

iPlayerInfo & iPlayerInfo::operator = (const iPlayerInfo & other)
{
	this->action_type=other.action_type;
	this->betSize=other.betSize;
	this->cards[0]=other.cards[0];
	this->cards[1]=other.cards[1];
	this->nik=other.nik;
	this->isActive=other.isActive;
	this->player_ai=other.player_ai;
	this->seatNumber=other.seatNumber;
	this->stack=other.stack;
	this->sitout=other.sitout;
	return *this;
}


void iPlayerInfo::update_info()
{

	try
	{
		//EZLOGGERSTREAM << "plUpdate" << std::endl;
	if(seatNumber>=0 && seatNumber<9)
		{
			nik=string(sfGlobals::GetSingleton()->m_holdem_state[(sfGlobals::GetSingleton()->m_ndx)&0xff].m_player[seatNumber].m_name);
			//EZLOGGERSTREAM << nik << std::endl;
			stack=(int)(sfGlobals::GetSingleton()->m_holdem_state[(sfGlobals::GetSingleton()->m_ndx)&0xff].m_player[seatNumber].m_balance);
			//EZLOGGERSTREAM << stack << std::endl;
			betSize=(int)(sfGlobals::GetSingleton()->m_holdem_state[(sfGlobals::GetSingleton()->m_ndx)&0xff].m_player[seatNumber].m_currentbet);
			//EZLOGGERSTREAM << betSize << std::endl;
			cards[0]=sfGlobals::GetSingleton()->m_holdem_state[(sfGlobals::GetSingleton()->m_ndx)&0xff].m_player[seatNumber].m_cards[0];
			cards[1]=sfGlobals::GetSingleton()->m_holdem_state[(sfGlobals::GetSingleton()->m_ndx)&0xff].m_player[seatNumber].m_cards[1];

		}
	}
	catch (...)
	{
		EZLOGGERSTREAM << "update exception" << std::endl;
		throw;
	}
}